package com.moonspring.contronller;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.moonspring.dao.UserDao;
import com.moonspring.model.UserModel;

@WebServlet("/user/regist")
public class UserRegistController extends HttpServlet{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@Override
	protected void service(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		String username = request.getParameter("username");
		String pwd = request.getParameter("pwd");
		String regCode = request.getParameter("reqcode");
		UserModel u = new UserModel();
		u.setPwd(pwd);
		u.setUserName(username);
		u.setRegistCode(regCode);
		UserDao ud = new UserDao();
		int r = ud.addUser(u);
		response.getWriter().write(r);
	}
}
